<?php

namespace App\Http\Middleware;
use DB;
use Closure;

class AdminLoginMiddleware
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {

        if(session('uid')){
            $res=DB::table('users')->where('uid',session('uid'))->first();
            if($res->userauth > 2){
                return $next($request);
            }else{
                 return redirect('/admin/login/index')->with('error','您的权限不够...');  
            } 
        }else{
            return redirect('/admin/login/index')->with('error','您还未登录');
        }   
            
            
        
    }
}
